<!doctype html>
<html><head>
</head><body>
	<p>WebViewJavascriptBridgeTests - echo.html</p>
	<script>
	function setupWebViewJavascriptBridge(callback) {
		if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
		if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
		window.WVJBCallbacks = [callback];
		var WVJBIframe = document.createElement('iframe');
		WVJBIframe.style.display = 'none';
		WVJBIframe.src = 'https://__bridge_loaded__';
		document.documentElement.appendChild(WVJBIframe);
		setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
	}

	setupWebViewJavascriptBridge(function(bridge) {
		bridge.callHandler('Greet', 'Hello world');
		bridge.registerHandler('echoHandler', function(data, responseCallback) {
			responseCallback(data)
		})
		bridge.registerHandler('jsRcvResponseTest', function(data, responseCallback) {
			bridge.callHandler('objcEchoToJs', { foo:'bar' }, function(response) {
				if (response && response.foo == 'bar') {
					responseCallback("Response from JS")
				} else {
					responseCallback("Failed")
				}
			})
		})
	})
	</script>
</body></html>
